import Express from 'express';
import fetch from 'node-fetch';
import 'babel-polyfill';

let app = Express();

app.get('/', (req, res) => {
    const f = () => {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve("234");
            }, 10000);
        });
    };

    const ajax = () => {
        return fetch("https://www.taobao.com").then(response=>{
            return response.text()
        })
    };

    const testAsync = async () => {
        try {
            const t = await ajax();
            res.send(t)
        } catch (err) {
            res.send("123"+err)
        }
    };

    testAsync();
});

app.listen(8888, () => console.log('server is running at http://localhost:8888'));